﻿Imports ISNet.WebUI.WebGrid

Partial Class mtFundCenterCmmtListPopup
    Inherits System.Web.UI.Page
    Public ScriptText As String
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Session("users") Is Nothing Then
            ScriptText = "<script> window.parent.TINY.box.hide();</script>"
        End If
        If IsPostBack = False Then
            Dim adapter As New MasterDataSetTableAdapters.FundCenterCmmtsTableAdapter
            Dim dtTable As New MasterDataSet.FundCenterCmmtsDataTable
            dtTable = adapter.GetDataByID(Val(Request("UID")))

            Dim cfrom As String
            Dim cto As String
            Dim planyear As Integer
            For Each row As MasterDataSet.FundCenterCmmtsRow In dtTable
                cfrom = row.FromCmmt_CmmtCode
                cto = row.ToCmmt_CmmtCode
                planyear = row.planyear
            Next
            
            Session("cfrom") = cfrom
            Session("cto") = cto
            L_FundCenter.Text = "รายการ Commitment จาก " & cfrom & " ถึง " & cto

            'Dim adapter As New MasterDataSet2TableAdapters.CmmtsTableAdapter
            'Dim data As New MasterDataSet2.CmmtsDataTable
            'data = adapter.GetDataByCmmtsCodeFrom_To_Year(cfrom, cto, Val(Request("IDYear"))) '"0010", "0020", 2557) 
            'GridView1.DataSource = data
            'GridView1.DataBind()

        End If
    End Sub
    Protected Sub WebGrid1_InitializeDataSource(ByVal sender As Object, ByVal e As ISNet.WebUI.WebGrid.DataSourceEventArgs) Handles WebGrid1.InitializeDataSource
        Dim adapter As New MasterDataSet2TableAdapters.CmmtsTableAdapter
        Dim data As New MasterDataSet2.CmmtsDataTable
        adapter.GetDataByCmmtsCodeFrom_To_Year(Session("cfrom"), Session("cto"), Val(Session("PlanYearTxt")))

        Session("count_data") = data.Rows.Count

        e.DataSource = adapter.GetDataByCmmtsCodeFrom_To_Year(Session("cfrom"), Session("cto"), Val(Session("PlanYearTxt")))

    End Sub

    Protected Sub WebGrid1_InitializeRow(ByVal sender As Object, ByVal e As ISNet.WebUI.WebGrid.RowEventArgs)
        ' don't edit column
        e.Row.Cells(0).ForceNoEdit = True
        e.Row.Cells(1).ForceNoEdit = True

    End Sub
End Class
